package cate.game.pvp.throne;

import cate.common.table.activity.tbboss.TBBossGroupRow;
import cate.game.play.proce.play.PlayPO;
import cate.game.role.Role;
import cate.game.role.farm.AbstractFarmFTC;
import cate.game.role.pvp.throne.RoleTBZoneBoss;
import cate.game.role.pvp.throne.msg.TBZoneBossChallengeResp;

public class TBZoneBossFTC extends AbstractFarmFTC<RoleTBZoneBoss> {

	private boolean sim;

	private TBBossGroupRow bossRow;

	@Override
	protected RoleTBZoneBoss po(Role role) {
		return role.getPvp().throne.zoneBoss;
	}

	public TBZoneBossFTC(Role role, boolean sim, TBBossGroupRow bossRow) {
		setup(role);
		this.sim = sim;
		this.bossRow = bossRow;
	}

	@Override
	public void handleResult(Role role, PlayPO playPO) {
		super.handleResult(role, playPO);
		TBZoneBossChallengeResp resp = new TBZoneBossChallengeResp();
		resp.win = true;
		if (!sim && role.getGame().pvp.throne.data.holder.base.timeTable.inZoneBoss()) {
			RoleTBZoneBoss zoneBoss = po(role);
			zoneBoss.hpExtend.recordByTid(playPO.teamEnd.b);
			zoneBoss.challengeTime++;
			zoneBoss.kill = zoneBoss.hpExtend.getTidRates().getOrDefault(bossRow.bossTid, 1d) <= 0d;
			zoneBoss.noticeUpdate();
		}
		role.sendNow(resp);
	}

}
